package com.fan.shop.mock;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

import com.fan.shop.dao.StoreDaoImpl;
import com.fan.shop.domain.Store;
import com.fan.shop.hibernate.utils.HibernateUtil;

public class StoreMock {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		StoreMock storeMock = new StoreMock();
		storeMock.insertStores();

	}

	
	public void insertStores()
	{
		SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
		Session session = sessionFactory.getCurrentSession();
		Transaction transaction = session.beginTransaction();

		StoreDaoImpl storeDaoImpl = new StoreDaoImpl();
		storeDaoImpl.setSessionFactory(sessionFactory);
		
		for(int i = 0; i < 50; i++)
		{
			Store store = new Store();
			store.setStoreCode(i + "" + i + "" + i);
			store.setStoreName(store.getStoreCode());
			store.setAddress("address_" + store.getStoreCode());
			
			storeDaoImpl.addStore(store);
		}
		transaction.commit();
	}
	
}
